package com.zxx.yuanze.lod;

import java.util.List;

/**
 * LOD 迪米特原则
 *
 * @author zxx on 2020/12/8
 */
public class Tenant {

    public float roomArea;
    public float roomPrice;
    public static final float diffA = 0.001f;
    public static final float diffP = 100.001f;


    //这个也关联 Room类了，所以最好提取到Mediator里（这就是LOD）
    public void rentRoom(Mediator mediator) {
        List<Room> rooms = mediator.getAllRooms();

        for (Room room : rooms) {
            if (isSuitable(room)) {
                System.out.println("租到房间啦! " + room);
                break;
            }
        }
    }

    // 租金要小于等于指定的值,面积要大于等于指定的值
    private boolean isSuitable(Room room) {
        return room.price <= roomPrice
                && room.area >= roomArea;
    }


}
